﻿using Mate.Caching;
using Mate.Dto.Users;
using Mate.Framework.Engine;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Mate.Framework.BaseController.Api
{
    [Produces("application/json")]
    [ApiController]
    public class BaseController: ControllerBase
    {
        private MpUserLoginDto loginDto;

        #region 获取当前登录用户
        /// <summary>
        /// 获取当前登录用户
        /// </summary>
        protected MpUserLoginDto CurrentUser(string token)
        {
            if (string.IsNullOrWhiteSpace(token))
            {
                return null;
            }
            if (loginDto != null)
            {
                return loginDto;
            }
            var cache = EngineContainerFactory.Context.GetInstance<ICacheManager>();
            return cache.Get<MpUserLoginDto>(token);
        }
        #endregion


    }
}
